package cn.hh.wechatkit.pojo.message;

import cn.hh.wechatkit.exception.Wx_Exception_InvalidParam;

import java.util.HashMap;
import java.util.Map;

/**
 * Created this one by HMH on 2017/7/11.
 */
public enum Wx_EventTypeEnum {

    card_pass_check("卡券过审"),
    user_get_card("领取卡券"),
    user_gifting_card("转赠卡券"),
    user_del_card("删除卡券"),
    user_consume_card("核销卡券"),
    user_pay_from_pay_cell("买单"),
    user_view_card("点入会员卡"),
    user_enter_session_from_card("从卡券点入公众号会话"),
    update_member_card("会员卡更新"),
    card_sku_remind("库存警报"),
    card_pay_order("流水变动"),
    submit_membercard_user_info("会员卡激活"),
    ;

    String eventName;

    Wx_EventTypeEnum(String eventName) {
        this.eventName = eventName;
    }


    private static final Map<String, Wx_EventTypeEnum> stringToEnum = new HashMap<>();
    static{
        for(Wx_EventTypeEnum e : values()){
            stringToEnum.put(e.name(), e);
        }
    }

    public static Wx_EventTypeEnum fromString(String name,String fieldName){
        Wx_EventTypeEnum result = stringToEnum.get(name);
        if (result == null) {
            throw new Wx_Exception_InvalidParam(fieldName+"枚举字段错误");
        }
        return result;
    }
}
